﻿namespace sBlog.Net.Memcache
{
    public abstract class CachingProvider
    {
        private static CachingProvider _objProvider = null;
        private static readonly string _defaultConfigPath = "/Memcached.config";

        public static CachingProvider Instance()
        {
            if (_objProvider == null)
                _objProvider = new MemcachedProvider(_defaultConfigPath);

            return _objProvider;
        }

        public static CachingProvider Instance(string configFile)
        {
            if (_objProvider == null)
                _objProvider = new MemcachedProvider(configFile);

            return _objProvider;
        }

        public abstract long DefaultExpireTime { get; set; }
        public abstract string KeySuffix { get; set; }

        public abstract bool Add(string strKey, object objValue);
        public abstract bool Add(string strKey, object objValue, bool bDefaultExpire);
        public abstract bool Add(string strKey, object objValue, long lNumofMilliSeconds);

        public abstract object Get(string strKey);

        public abstract bool Remove(string strKey);
        public abstract bool RemoveAll();
        public abstract ulong? Increment(string key, ulong amount);
        public abstract ulong? Decrement(string key, ulong amount);

        public abstract string GetHostStatus();
    }
}
